<?php

namespace App\Validator\Admin\Rbac;

use App\Validator\BaseValidator;

class RoleValidator extends BaseValidator
{

    protected array $attr = [
        'id' => '角色id',
        'ids' => '角色id',
        'name' => '角色名称',
    ];

    public function add($data)
    {
        return $this->validate($data,[
            'name' => ['required','string',]
        ]);
    }

    public function update($data)
    {
        return $this->validate($data,[
            'id' => ['required','integer','min:1'],
            'name' => ['required','string',],
        ]);
    }

    public function del($data)
    {
        return $this->validate($data,[
            'ids' => ['required','array','min:1'],
            'ids.*' => ['required','integer','min:1'],
        ]);
    }

    public function bindRoutes($data)
    {
        return $this->validate($data,[
            'id' => ['required','integer','min:1'],
            'route_ids' => ['required','array','min:1'],
            'route_ids.*' => ['required','integer','min:1'],
        ]);
    }

    public function detail($data)
    {
        return $this->validate($data,[
            'id' => ['required','integer','min:1'],
        ]);
    }
}
